﻿

macro(copy_service_include_files)
   file(GLOB service_files ${CMAKE_CURRENT_SOURCE_DIR}/services/*.h)
   file(COPY ${service_files} DESTINATION ${USK_SERVICES_INCLUDE_DIR}/services)
endmacro()


macro(USKConfigExport)

   string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
   set(USKExportConfigFileH ${CMAKE_CURRENT_BINARY_DIR}/include/usk/${PROJECT_NAME_LOWER}_export.h)
   configure_file(${USK_SOURCE_DIR}/cmake/export.h.in
      ${USKExportConfigFileH}
   )

endmacro()


macro(USKCreateApplication)
   cmake_parse_arguments(CA
      ""
      "APPLICATION_NAME;TARGET_NAME"
      "INCLUDE_DIRS;LINK_LIBRARIES;SOURCES;HEADERS"
      ${ARGN}
   )

   if(NOT CA_APPLICATION_NAME)
      message(FATAL_ERROR "USKCreateApplication缺少参数APPLICATION")
   endif()
   set(APPLICATION_NAME ${CA_APPLICATION_NAME})

   if(NOT CA_TARGET_NAME)
      message(FATAL_ERROR "USKCreateApplication缺少参数TARGET_NAME")
   endif()

   set(MAIN_ENTRY_FILE ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
   if(NOT EXISTS ${MAIN_ENTRY_FILE})
      configure_file(${USK_SOURCE_DIR}/cmake/application.cpp.in
         ${MAIN_ENTRY_FILE}
      )
   endif()

   list(APPEND CA_SOURCES ${MAIN_ENTRY_FILE})

   add_executable(${CA_TARGET_NAME} ${CA_SOURCES}  ${CA_HEADERS})

   target_link_libraries(${CA_TARGET_NAME}
      PUBLIC 
      USKCore
      ${CA_LINK_LIBRARIES}
   )

   target_include_directories(${CA_TARGET_NAME}
      PUBLIC ${CA_INCLUDE_DIRS}
   )




endmacro()
